//基本类型声明
let a: number = 10
let b: string = 'Hello World'
let c: boolean = true
let d: any = 'Hello World'
let e: undefined = undefined
let f: null = null
let g: void = undefined
let h: symbol = Symbol('key')
let i: object = { name: 'John', age: 30 }
let j: never = undefined as never // 类型断言
//引用数据类型
let k: Array<number> = [1, 2, 3]
let l: Object = { name: 'John', age: 30 }
let m: Function = function () {}
let n: Date = new Date()
let o: RegExp = /hello/i
//自定义类型
// 类型别名
type MyType = number
let p: MyType = 10
//联合类型
type MyUnionType = string | number
let q: MyUnionType = 'Hello World'
// 联合交叉类型
type Gender = 'male' | 'female'
type pig = {
  name: string
  age: number
  info: {
    eat: Boolean
  }
}
type Person = {
  info: {
    gender: Gender
    hobbies: string[]
  }
}
const person: Person & pig = {
  name: 'John',
  age: 30,
  info: {
    gender: 'male',
    eat: true,
    hobbies: ['reading', 'swimming'],
  },
}
// fanxing
// type foods<T extends {flag:boolean}> = {
type foods<T = {flag:boolean}> = {
  name: string,
  info:T
}
// const apple:foods<{flag:boolean,hobby:string[]}> = {
const apple:foods = {
  name: 'apple',
  info: {
    flag: true,
    // hobby: ['red', 'green']
  }
}
// 条件
// 1 继承
class male{}
class man extends male{}
// 2 泛型
function fn<T extends {id:number}>(args:T):T{
  return args
}  
fn({id:1,name:'zhangsan'})
// 3 
type isString<T> = T extends string? true : false;
const a1:isString<string> = true; 